﻿<navigation:Page x:Class="Songhay.Silverlight.Mvvm.Views.ApplicationMessagePage"
    x:Name="ApplicationMessageNavigationPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    xmlns:vm="clr-namespace:Songhay.Silverlight.Mvvm.ViewModels"
    mc:Ignorable="d"
    d:DesignWidth="640" d:DesignHeight="480">
    <navigation:Page.Resources>
        <vm:ApplicationMessagePageViewModel x:Key="ApplicationMessagePageViewModelDataSource" d:IsDataSource="True" />
    </navigation:Page.Resources>
    <navigation:Page.DataContext>
        <Binding Mode="OneWay" Source="{StaticResource ApplicationMessagePageViewModelDataSource}" />
    </navigation:Page.DataContext>
    <StackPanel Background="#99000000" VerticalAlignment="Center">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="Error">
                    <Storyboard>
                        <ColorAnimation Duration="0" To="Red" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="PageTitle" d:IsOptimized="True"/>
                        <ColorAnimation Duration="0" To="Red" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="PageMessage" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Default"/>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsErrorMessage}" Value="True">
                <ei:GoToStateAction x:Name="GoToErrorState" StateName="Error" TargetObject="{Binding ElementName=ApplicationMessageNavigationPage}" />
            </ei:DataTrigger>
            <ei:DataTrigger Binding="{Binding IsErrorMessage}" Value="False">
                <ei:GoToStateAction x:Name="GoToDefaultState" StateName="Default" TargetObject="{Binding ElementName=ApplicationMessageNavigationPage}" />
            </ei:DataTrigger>
        </i:Interaction.Triggers>
        <TextBlock x:Name="PageTitle"
            FontSize="24"
            FontFamily="Consolas"
            HorizontalAlignment="Stretch"
            Margin="24"
            Text="{Binding PageTitle}"
            TextAlignment="Center" Foreground="White" />
        <TextBlock x:Name="PageMessage"
            FontSize="18"
            FontFamily="Consolas"
            HorizontalAlignment="Stretch"
            Margin="0,0,0,24"
            Text="{Binding ApplicationMessage}"
            TextAlignment="Center" Foreground="White" />
    </StackPanel>
</navigation:Page>
